package com.shop.service.impl;

import com.shop.mapper.IUserEditMapper;
import com.shop.pojo.CommonResult;
import com.shop.pojo.UserDTO;
import com.shop.service.IUserEditService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserEditServiceImpl implements IUserEditService {


    @Resource
    private IUserEditMapper userEditMapper;

    @Override
    public CommonResult<Boolean> addUser(UserDTO userDTO) {
        Boolean isSuccess = userEditMapper.addUser(userDTO);
        return new CommonResult<>(201, "success", isSuccess);
    }

    @Override
    public CommonResult<Integer> editUserState(boolean state, String id) {
        Integer matchedRows = userEditMapper.editUserState(state, id);
        return new CommonResult<>(200, "success", matchedRows);
    }

    @Override
    public CommonResult<Integer> editUser(UserDTO userDTO) {
        Integer matchedRows = userEditMapper.editUser(userDTO);
        return new CommonResult<>(201, "success", matchedRows);
    }

    @Override
    public CommonResult<Integer> removeUserById(int id) {
        Integer affectedRows = userEditMapper.removeUserById(id);
        return new CommonResult<>(200, "success", affectedRows);
    }


}
